//
//  MPGuideController.m
//  MarkPlatform
//
//  Created by xiao6 on 2017/12/18.
//  Copyright © 2017年 AT. All rights reserved.
//

#import "MPGuideController.h"
#import "MPGuideCell.h"

@interface MPGuideController ()
{}
@property (nonatomic, strong) NSMutableArray<NSString *> *dataList;
@end

@implementation MPGuideController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self showNavTitle:@"使用指南" backItem:YES];
    
    self.dataList = [NSMutableArray array];
    if (kIsiPhoneX) {
        [self.dataList addObject:@"guide_01_iphonex"];
        [self.dataList addObject:@"guide_02_iphonex"];
        [self.dataList addObject:@"guide_03_iphonex"];
    }
    else {
        [self.dataList addObject:@"guide_01"];
        [self.dataList addObject:@"guide_02"];
        [self.dataList addObject:@"guide_03"];
    }
}

#pragma mark - Delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataList.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MPGuideCell *cell = [MPGuideCell cellForCollectionView:collectionView indexPath:indexPath];
    cell.imageView.image = [UIImage imageNamed:self.dataList[indexPath.row]];
    return cell;
}

#pragma mark - getter
- (UICollectionView *)collectionView {
    if (!_collectionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.minimumLineSpacing = 0;
        layout.minimumInteritemSpacing = 0;
        layout.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - NAVI_HIGHT);
        _collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor appCollectionBackgroundColor];
        _collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
        _collectionView.pagingEnabled = YES;
        if (@available(iOS 11.0, *)) {
            _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        } else {
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
        _collectionView.contentInset = UIEdgeInsetsMake(NAVI_HIGHT, 0, 0, 0);
        _collectionView.showsHorizontalScrollIndicator = NO;
    }
    return _collectionView;
}
@end
